<%@page import="javax.xml.soap.Detail"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%
         request.setCharacterEncoding("UTF-8");
%>
<%@ page import="java.sql.*" %>
<html>
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>Getpassword</title>
		  <style type="text/css">
                       body{
                           background-image: url('photo/getpassword.jpg');
                           background-size:cover;  
                         }
                    </style>
  </head>
<body scroll = no>
</br>

            <style>
                .test {
                 font-size: 30px;
                 text-align: center;
                 color: #FFFFFF;
                  font-family : 微软雅黑,宋体, 'New York';
                }
                </style >

<table>
<td style="padding-right:130px" >
                           <form action="login.html" method="post" onsubmit="return checkForm(this);">
                                 <input type="submit" value="返回上页" name="back" style="width:90; height:33;font-size:16px;color:#FFFFFF;background-color:#000000;">
                                </form>
                         </td>
</table>
<hr>

<form action=""  name="getpassword"  onsubmit="return checkForm(this);">

<p align="center" class="test">Fill in your registration information</p>
<table border=3  align="center">

<tr >
<td>姓名:</td><td><input type="text" size=60 name="username"></td>
</tr>
<tr >

<td>性别:</td><td><input type="text" size=60 name="sex"></td>
</tr>

<tr >
<td>邮箱:</td><td><input type=text size=60 name="email"></td>
</tr>
　　　    
     <tr align=center>
     <td colspan=2><input type="submit" name="submit" value="确认" >
     <input type=reset value="重置内容"></td>
     </tr>

     </table>

<%
Statement sql;
Connection con;
ResultSet rs;
   try{
       Class.forName("com.mysql.jdbc.Driver");
       }
       catch(Exception e){
           out.print("123");
       };


        try{

                String uri="jdbc:mysql://localhost:3306/sharing";

           con = DriverManager.getConnection(uri,"root","ZHUBI123.");
        if (request.getParameter("username") != null
            && request.getParameter("sex") != null
                && request.getParameter("email") != null) {
        String username = request.getParameter("username");
        String sex = request.getParameter("sex");
        String email = request.getParameter("email");
        String condition = "select * from student where username='" + username+
                     "' and sex='" + sex + "' and email='" + email + "'";
        sql=con.createStatement();
                rs = sql.executeQuery(condition);//匹配数据库信息
                if (rs.next()) {
                        String password = rs.getString(3);
                        String errmsg = "Success and Your Password：";
                out.println("<center><font color=green size=5>提示:<hr></font><font color=red size=4>"
                                                        + errmsg + password + "</font><hr>");

                }
                else {
                String errmsg = "Sorry, your information is wrong";
                out.println("<center><font color=green size=5>提示:<hr></font><font color=red size=4>"
                                                        + errmsg + "</font><hr>");


                }
        }
        }
        catch(Exception e){
                 out.print("系统的错误");
        }
%>


     
     </body></html>

